package com.qcit.api

import android.annotation.SuppressLint
import android.app.Activity
import android.os.Build
import android.os.Bundle
import android.os.Parcelable
import androidx.annotation.RequiresApi
import androidx.fragment.app.Fragment
import java.io.Serializable
import java.security.AccessControlContext
import java.util.ArrayList

class BundleManager {
    val bundle = Bundle()
    var call:Call? = null
    fun withString(key:String,value:String):BundleManager{
        bundle.putString(key,value)
        return this;
    }

    fun withInt(key:String,value:Int):BundleManager{
        bundle.putInt(key,value)
        return this;
    }
    fun withBoolean(key:String,value:Boolean):BundleManager{
        bundle.putBoolean(key,value)
        return this;
    }
    fun withBundle(key:String,value:Bundle):BundleManager{
        bundle.putBundle(key,value)
        return this;
    }
    fun withSerializable(key:String,value: Serializable):BundleManager{
        bundle.putSerializable(key,value)
        return this;
    }
    fun withParcelableArrayList(key:String, values: ArrayList<out Parcelable>?):BundleManager{
        bundle.putParcelableArrayList(key, values)
        return this;
    }
    @SuppressLint("NewApi")
    fun navigation(aty:Activity):Any?{
        return navigation(aty,null)
    }
    @SuppressLint("NewApi")
    fun navigation(aty:Activity,code:Int?):Any?{
        return ARouterManager.instance.navigation(aty,this,null)
    }
    @SuppressLint("NewApi")
    fun navigation(fag:Fragment):Any?{
        return  navigation(fag,null)
    }
    @SuppressLint("NewApi")
    fun navigation(fag:Fragment,code:Int?):Any?{
        return ARouterManager.instance.navigation(fag,this,code)
    }
}